/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.portalcenter.api;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hallele.infrastructure.metadata.io.R;
import cn.hallele.infrastructure.metadata.io.Response;
import cn.hallele.mc.sdk.portalcenter.api.MenuApi;
import cn.hallele.mc.sdk.portalcenter.common.constants.ReqPathConst;
import cn.hallele.mc.sdk.portalcenter.dto.MenuDTO;
import cn.hallele.mc.sdk.portalcenter.dto.MenuQueryDTO;
import cn.hallele.ms.infrastructure.auditlog.annotation.ApiLog;
import cn.hallele.ms.portalcenter.das.MenuDBDas;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * hallele_ms_portalcenter
 *
 * @author anle5
 * @since 2024/10/12 22:29
 */
@RestController
@RequestMapping(ReqPathConst.MENU_V1)
public class MenuController implements MenuApi {
    @Autowired
    private MenuDBDas menuDBDas;

    /**
     * 获取 路由列表
     *
     * @return List
     */
    @Override
    @SaCheckLogin
    @ApiLog(id = "MENU_V1_GET_ROUTES")
    public Response<List<MenuDTO>> getRoutes() {
        List<MenuDTO> routes = menuDBDas.getRoutes();
        return R.ok(routes);
    }

    /**
     * 获取 菜单列表
     *
     * @param condition 查询条件
     * @return 系统菜单
     */
    @Override
    @SaCheckLogin
    @ApiLog(id = "MENU_V1_GET_MENUS")
    public Response<List<MenuDTO>> getMenus(@Valid MenuQueryDTO condition) {
        List<MenuDTO> menus = menuDBDas.getMenus(condition);
        return R.ok(menus);
    }
}
